package com.wn.inventory.web;

import com.wn.common.PageBean;
import com.wn.common.ResponseEntity;
import com.wn.entity.BorrowWarehouseApplication;
import com.wn.entity.ScrapApplication;
import com.wn.inventory.service.ScrapApplicationService;
import com.wn.inventory.vo.BorrowWarehouseApplicationVo;
import com.wn.inventory.vo.ScrapApplicationVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @ author     ：NST
 * @ date       ：Created in 2022/10/22 14:44
 * @ description：
 * @ modified By：
 * @ version:
 */
@RestController
@RequestMapping("inventory/scrap")
public class ScrapApplicationVoController {
    @Autowired
    ScrapApplicationService scrapApplicationService;

    /**
     * @param scrapApplication
     * @return com.wn.common.ResponseEntity
     * @ author nst
     * @ date 2022/10/21 14:28
     * @ Description 需要提供库存台账id,数量,报废原因
     */
    @RequestMapping("add")
    public ResponseEntity add(@RequestBody @Validated ScrapApplication scrapApplication, HttpServletRequest request) {
        scrapApplicationService.insert(scrapApplication,request);
        return ResponseEntity.success;
    }

    @RequestMapping("addition")
    public ResponseEntity getByCondition(@RequestBody ScrapApplicationVo scrapApplicationVo) {
        PageBean<ScrapApplication> pageBean = scrapApplicationService.getByCondition(scrapApplicationVo);
        return new ResponseEntity(pageBean);
    }
}
